package com.vhall.component.controller.rbac;


import com.vhall.component.controller.rbac.facade.RbacAccessFacade;
import com.vhall.component.entity.rbac.vo.*;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.service.rbac.RbacAccessOpLogService;
import com.vhall.component.service.rbac.RbacAccessService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * @author dalong
 * @date 2021-05-10 16:53
 */
@Slf4j
@VhallComponent
@VssTokenAuth
public class RbacAccessController implements RbacAccessFacade {

    @Autowired
    private RbacAccessService accessService;

    @Autowired
    private RbacAccessOpLogService accessOpLogService;

    @ApiOperation("获取权限列表")
    @Override
    public List<AccessVO> list(@Validated AccessListReqVO reqVO) {
        reqVO.setPage(1);
        reqVO.setPageSize(20);
        return accessService.list(reqVO);
    }

    @ApiOperation("获取用户的操作记录")
    @Override
    public List<AccessOpLogVO> getLog(@Validated AccessOpLogListReqVO reqVO) {
        return accessOpLogService.list(reqVO);
    }

    @ApiOperation("获取用户权限列表")
    @Override
    public List<Integer> userList(@Validated AccessUserListReqVO reqVO) {
        return accessService.userAccessList(reqVO);
    }

    @ApiOperation("导入权限表")
    @Override
    public Boolean add() {
        return accessService.add();
    }
}
